package com.mahjong.server.client.test;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import com.mahjong.server.component.logic.entity.PlayerMahjong;
import com.mahjong.server.component.logic.main.KHMahjongAction;
import com.mahjong.server.component.logic.main.KHMahjongLogic;
import com.mahjong.server.component.logic.manager.LogicManager;

/**
 * @user:   Administrator
 * @author： 游刚
 * @version：1.0
 * @created：Apr 11, 2013
 */

public class MjLogicTest2 {
	
	int roomId = 1000;
	KHMahjongAction action = new KHMahjongAction();
	KHMahjongLogic logic = new KHMahjongLogic();
	
	@Before
	public void init() {
		System.out.println("init().....");
		LogicManager manager = new LogicManager();
		manager.init(roomId);
	}
	
	@Test
	public void testQiDui() {
		String pai1 = "萬8_4";
		String[] pais1 = {"萬3_1", "萬3_2", "萬5_3","萬5_1", "萬8_3","筒3_3","筒3_4" ,"6發_1", "6發_2", "1东_1", "1东_2",  "4北_1",  "4北_2"};
		pais1 = action.gang(pai1, pais1);
		for(String p : pais1) {
			System.out.println(p);
		}
	}
	
	//测试数组中有多少个重复的元素
	@Test
	public void testChongFu() {
		String[] arr = {};
		Map<String,String> map = new HashMap<String,String>();
		for(String s : arr) {
			map.put(s, s);
		}
		System.out.println(arr.length);
		System.out.println(map.size());
	}
	
	@Test
	public void testPingHu() {
		PlayerMahjong pm1 = new PlayerMahjong();
		pm1.setShouZhong(new String[]{"萬1_2", "萬2_2", "萬3_2","萬3_3", "萬4_2", "萬5_2","条4_4","4北_1","4北_2","4北_4", "5中_4", "6發_4", "7白_4"});
		int n1 = logic.pingHu("条4_2", pm1);
		System.out.println("=========pm1结果："+n1+"===========");
		PlayerMahjong pm2 = new PlayerMahjong();
		pm2.setShouZhong(new String[]{ "萬1_1","萬1_3","萬2_1","萬2_3","萬3_1","萬3_3","条4_2","条4_4","1东_1","4北_4", "7白_1", "7白_2", "7白_4"});
		int n2 = logic.pingHu("2南_2", pm2);
		System.out.println("=========pm2结果："+n2+"===========");
		PlayerMahjong pm3 = new PlayerMahjong();
		pm3.setShouZhong(new String[]{ "萬1_1","萬1_3","萬2_1","萬2_3","萬3_1","萬3_3","筒2_3","筒3_1","条4_2","条4_4",});
		int n3 = logic.pingHu("筒4_2", pm3);
		System.out.println("=========pm3结果："+n3+"===========");
	}
	
	
}
